<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:p="http://primefaces.org/ui">

    <ui:composition template="/template.xhtml">
        <ui:define name="title">
            <h:outputText value="#{bundle.ListCoursesTitle}"></h:outputText>
        </ui:define>
        <ui:define name="mainMenu">
        <h:form>
                <div id="topmenu">
                    <ul>
                       <li >
                            <h:commandLink action="#{usersController.prepareList()}" value="Admin"/>
                        </li>
                        <li>
                            <h:commandLink action="#{classesController.prepareList()}" value="Classes"/>
                        </li>
                        <li class="current">
                            <h:commandLink action="#{coursesController.prepareList()}" value="Courses"/>
                        </li>
                        <li>
                            <h:commandLink action="#{examsController.prepareList()}" value="Examination"/>
                        </li>
                    </ul>
                </div>
                </h:form>
        </ui:define>
        <ui:define name="body">
            <div id="box">
                <h3>List of Courses</h3>
            <h:form styleClass="jsfcrud_list_form">
                <h:panelGroup id="messagePanel" layout="block">
                    <h:messages errorStyle="color: red" infoStyle="color: green" layout="table"/>
                </h:panelGroup>
                <h:outputText escape="false" value="#{bundle.ListCoursesEmpty}" rendered="#{coursesController.items.rowCount == 0}"/>
                <h:panelGroup rendered="#{coursesController.items.rowCount > 0}">
                    <p:dataTable value="#{coursesController.items}" var="item" paginator="true" rows="10"  
                                     paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"  
                                     rowsPerPageTemplate="5,10,15" style="width: 100%" >
                        <p:column>
                            <f:facet name="header">
                                <h:outputText value="#{bundle.ListCoursesTitle_id}"/>
                            </f:facet>
                            <h:outputText value="#{item.id}"/>
                        </p:column>
                        <p:column>
                            <f:facet name="header">
                                <h:outputText value="#{bundle.ListCoursesTitle_courseName}"/>
                            </f:facet>
                            <h:outputText value="#{item.courseName}"/>
                        </p:column>
                        <p:column style="width: 200px">
                            <f:facet name="header">
                                <h:outputText value="&nbsp;"/>
                            </f:facet>
                            <h:commandButton action="#{coursesController.prepareEdit()}"
                                                 image="#{resource['img:edit.png']}">
                                    <f:setPropertyActionListener value="#{item}" target="#{coursesController.selected}"/>
                                </h:commandButton>
                                <h:commandButton action="#{coursesController.destroy}"
                                                 image="#{resource['img:delete.png']}">
                                    <f:setPropertyActionListener value="#{item}" target="#{coursesController.selected}"/>
                                </h:commandButton>
                                <h:commandButton action="#{coursesController.prepareView()}"
                                                 image="#{resource['img:view.gif']}">
                                    <f:setPropertyActionListener value="#{item}" target="#{coursesController.selected}"/>
                                </h:commandButton>
                        </p:column>
                    </p:dataTable>
                </h:panelGroup>
                <br />
                <h:commandLink action="#{coursesController.prepareCreate}" value="#{bundle.ListCoursesCreateLink}"/>
                <br />
                <br />
                
            </h:form>
            </div>
        </ui:define>
    </ui:composition>

</html>
